<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/8
 * Time: 9:06
 */

namespace plugin\admin\app\controller\admin;


use plugin\admin\app\controller\AuthController;
use plugin\admin\app\logic\admin\ManageLogic;
use support\Request;
use support\Response;

class ManageController extends AuthController
{
    /**
     *浏览
     * @param Request $request
     * @return Response
     * @throws \Throwable
     */
    public function index(Request $request): Response
    {
        return raw_view('admin/index');
    }

    /**
     * 查询
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function select(Request $request): Response
    {
        return ManageLogic::getInstance()->select($request);
    }

    /**
     * 插入
     * @param Request $request
     * @return Response
     * @throws \Throwable
     * @throws \support\exception\BusinessException
     */
    public function insert(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return ManageLogic::getInstance()->insert($request);
        }
        return raw_view('admin/insert');
    }


    /**
     * 更新
     * @param Request $request
     * @return Response
     * @throws \Throwable
     * @throws \support\exception\BusinessException
     */
    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return ManageLogic::getInstance()->update($request);
        }

        return raw_view('admin/update');
    }

    /**
     * 删除
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function delete(Request $request): Response
    {
        return ManageLogic::getInstance()->delete($request);
    }
}